//
//  ViewController.m
//  LYRefresh
//
//  Created by boom on 2017/5/3.
//  Copyright © 2017年 boomLi. All rights reserved.
//

#import "ViewController.h"
#import "LYRefresh.h"

#define screenH [UIScreen mainScreen].bounds.size.height
#define screenW [UIScreen mainScreen].bounds.size.width

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) LYRefresh * lj;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initScrollView];
}

/**
 初始化UIScrollView
 */
-(void)initScrollView{
    self.title = @"猪";
    self.automaticallyAdjustsScrollViewInsets = NO;
    //初始化一个UITableView
    UITableView* tableview = [[UITableView alloc] init];
    tableview.dataSource = self;
    tableview.delegate = self;
    tableview.frame = CGRectMake(0, 64, screenW, screenH-64);
    [tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    tableview.backgroundColor = [UIColor greenColor];
    
    _lj = [[LYRefresh alloc] init];
    
    __weak typeof(self) weakSelf = self;
    _lj.startBlock = ^{
        [weakSelf performSelector:@selector(setAAA) withObject:nil afterDelay:3];
    };
    _lj.endBlock = ^{
        NSLog(@"结束刷新....");
    };

    _lj.scrollView = tableview;
    
    [self.view addSubview:tableview];
    
   
}

-(void)setAAA{
    NSLog(@"1234567890");
    [_lj hide];
}

#pragma -- UITableViewDataSource

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    return cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
